package com.hy.study.reduce;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author huyong
 * @date 2024 年 02 月 06 日 10:05: 13
 */
public class FilterReducer extends Reducer<Text, NullWritable, Text, NullWritable> {
    @Override
    protected void reduce(Text key, Iterable<NullWritable> values, Reducer<Text, NullWritable, Text, NullWritable>.Context context) throws IOException, InterruptedException {
        String line = key.toString() + "\r\n";
        key.set(line);
        for (NullWritable value : values) { // 防止有重复的
            context.write(key, NullWritable.get());
        }
    }
}
